package org.cskt.sl.ebank.service.impl;

import java.util.List;

import org.cskt.sl.ebank.dao.BaseAccountMapper;
import org.cskt.sl.ebank.entity.BaseAccount;
import org.cskt.sl.ebank.entity.CommonExample;
import org.cskt.sl.ebank.service.BaseAccountService;
import org.cskt.sl.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
/**
 * 消费记录 service实现类
 * @author guddqs
 *
 */
public class BaseAccountServiceImpl implements BaseAccountService{

	@Autowired
	private BaseAccountMapper mapper;
	
	@Override
	public int countByExample(CommonExample example) {
		
		return mapper.countByExample(example);
	}

	@Override
	public int addBaseAccount(BaseAccount record) {
		return mapper.insert(record);
	}

	@Override
	public List<BaseAccount> getBaseAccountPageListByUserId(CommonExample example, Pager pager) {
		if(pager!=null){
			if(pager.getCurrentPage()!=null){
				int first=(pager.getCurrentPage()-1)*pager.getPageSize();
				int max=pager.getPageSize();
				return mapper.selectByExample(example, first, max);
			}
		}
		return null;
	}

	@Override
	public BaseAccount getBaseAccountById(Integer baid) {
		if(baid!=null){
			return mapper.selectByPrimaryKey(baid);
		}
		return null;
	}

}
